package org.uned.agonzalo16.bitacora.web.security;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.uned.agonzalo16.bitacora.service.security.AuthenticatedUser;
import org.uned.agonzalo16.bitacora.service.security.AuthenticationProvider;

@Controller
public class HomeController {

	@Autowired
	private AuthenticationProvider authenticationProvider;

	@RequestMapping({ "/" })
	public String index(HttpServletRequest request) {
		AuthenticatedUser user = authenticationProvider.getCurrentUserDetails();

		if (user == null) {
			return "index";
		} else {
			return "registerUser";
		}
	}
}
